package com.liugege.make.singleton;
/**
* @author: LiuGeGe
* @Date: 2022/3/2 16:18
* @Description(类描述):  通过静态内部类方式创建实例
* @Class(类): SingletonDemo4
*/
public class SingletonDemo4 {
    private  SingletonDemo4(){

    }
    private  static  class  SingletonDemo4Holder{
        private  final  static  SingletonDemo4 INSTANCE = new SingletonDemo4();
    }
    public static  SingletonDemo4 getInstance(){
        return SingletonDemo4Holder.INSTANCE;
    }

    public static void main(String[] args) {
        SingletonDemo4 instance = SingletonDemo4.getInstance();
        SingletonDemo4 instance1 = SingletonDemo4.getInstance();
        SingletonDemo4 instance2 = SingletonDemo4.getInstance();
        System.out.println(instance == instance1);
        System.out.println(instance == instance2);
        System.out.println(instance1 == instance2);
    }
}
